<template>
  <el-dialog title="所有权限" :visible.sync="dialogVisibleV">
    <el-table :data="data">
      <el-table-column
        property="name"
        label="权限码"
        width="150"
      ></el-table-column>
      <el-table-column
        property="displayName"
        label="名称"
        width="200"
      ></el-table-column>
      <el-table-column property="remark" label="备注"></el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
  import { getPermissionList } from '@/api/userManagement'

  export default {
    name: 'ShowPermissionList',
    props: {
      uid: {
        type: String,
        default: function () {
          return null
        },
      },
      dialogVisible: {
        type: Boolean,
        default: function () {
          return false
        },
      },
    },
    data() {
      return {
        data: [],
        dialogVisibleV: this.dialogVisible,
      }
    },
    watch: {
      dialogVisibleV: function (v) {
        this.$emit('update:dialogVisible', v)
      },
      dialogVisible: function (v) {
        this.dialogVisibleV = v
      },
      uid: function (v) {
        this.fetchData()
      },
    },
    methods: {
      async fetchData() {
        if (this.uid == null) {
          this.data = []
        } else {
          let resp = await getPermissionList(this.uid)
          this.data = resp.data
        }
      },
    },
  }
</script>

<style scoped></style>
